define([], function () {
    var MapLoader = {
        baseLayer:null,
        mapId:"map",
        view:null,
        map:null,
        projection:null,

        init: function(){
            this._initMap();
        },

        _initMap: function(){
            var self = this;
            self._initCopyright();
            self.baseLayer = self._getTdtLayer("vec_w");
            self.projection = new ol.proj.Projection({
                code: 'EPSG:3857',
                units: 'm'
            });
            self.view = new ol.View({
                projection: self.projection,
                center: [11972997.801030032, 4797557.489844433],
                zoom: 4,
                minZoom:2
            });
            self.map = new ol.Map({
                controls: ol.control.defaults({
                    attribution: false
                }),
                target: self.mapId,
                layers: [
                    self.baseLayer
                ],
                view:self.view
            });
        },
        _initCopyright: function () {
            $("#copyright").html("@Copyright LZUGIS");
        },
        _getTdtLayer: function(lyr){
            return new ol.layer.Tile({
                source: this._getTdtSource(lyr)
            })
        },
        _getTdtSource:function (lyr) {
            var url = "http://t0.tianditu.com/DataServer?T=" + lyr + "&X={x}&Y={y}&L={z}";
            return new ol.source.XYZ({
                url: url
            });
        }
    };
    return MapLoader;
});
